/*
 *  $Id: Graveyard.cs 881 2009-11-24 19:51:45Z thenn.erannor $
 *    This file is a part of Ragima CCG.
 *    (C) 2008 Ragima development group.
 *
 *    Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima {
    /// <summary>
    /// Условие на количество существ в могильнике.
    /// Параметры: вражеский или свой могильник, минимум или максимум, и число.
    /// </summary>
    public class GraveyardCondition: Condition {
        private bool _enemy, _max;
        private int _count;

        public GraveyardCondition(bool enemy, bool max, int count) {
            _enemy = enemy;
            _max = max;
            _count = count;
        }

        public override bool Test(AbstractObject caster, Card card) {
            Player owner = caster.Owner;
            if (_enemy) owner = owner.Enemy;
            int count = owner.Graveyard.Count;
            return _max ? count <= _count : count >= _count;
        }

        private static readonly Languages.Phrase OwnLesser = new Languages.Phrase("condition.graveyard.own.lesser");
        private static readonly Languages.Phrase OwnGreater = new Languages.Phrase("condition.graveyard.own.greater");
        private static readonly Languages.Phrase EnemyLesser = new Languages.Phrase("condition.graveyard.enemy.lesser");
        private static readonly Languages.Phrase EnemyGreater = new Languages.Phrase("condition.graveyard.enemy.greater");

        public override Languages.Phrase Notice {
            get { return _enemy ? (_max ? EnemyGreater : EnemyLesser) : (_max ? OwnGreater : OwnLesser); }
        }
        public override string NoticeText {
            get { return Notice.GetText(_count); }
        }
    }
}